package com.woniuxy.springparking.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.woniuxy.springparking.common.RestDto;
import com.woniuxy.springparking.common.RestResult;
import com.woniuxy.springparking.dao.TPerFeedbackDao;
import com.woniuxy.springparking.pojo.Log;
import com.woniuxy.springparking.pojo.TPerFeedback;
import com.woniuxy.springparking.pojo.TPerUser;
import com.woniuxy.springparking.service.TPerFeedbackService;
import com.woniuxy.springparking.vo.TPerFeedbackVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class TPerFeedbackServiceImpl implements TPerFeedbackService {
    @Autowired
    private TPerFeedbackDao tPerFeedbackDao;

    @Override
    public RestResult findTFByPage(TPerFeedbackVo tfVo) {
        Page<Object> pages= PageHelper.startPage(tfVo.getPage(),tfVo.getLimit());
        List<TPerFeedback> data=this.tPerFeedbackDao.selectTFByPage(tfVo);
        return new RestResult(pages.getTotal(),data);
    }

    @Override
    public List<TPerFeedback> findUserName(Integer[] ids) {
        List<TPerFeedback> tu=new ArrayList<>();
        for (Integer id:ids){
            tu.add(tPerFeedbackDao.selectUserNameById(id));
        }
        return tu;
    }

    @Override
    public void updateResultAndStatus(String perFeedbackResult, String perFeedbackStatus, Integer perFeedbackId) {
        this.tPerFeedbackDao.updateResultAndStatus(perFeedbackStatus,perFeedbackResult,perFeedbackId);
    }
}
